import type { User, CodeType, UserInfo, PatientList, Patient } from '@/types/user'
import { request } from '@/utils/request'

// 密码登录
export const loginByPassword = (mobile: string, password: string) => {
  return request<User>('/login/password', 'post', { mobile, password })
}

// 获取验证码
export const sendMObileCode = (mobile: string, type: CodeType) => {
  return request<{ code: string }>('/code', 'get', { mobile, type })
}

//验证码登录
export const loginByCode = (mobile: string, code: string) => {
  return request<User>('/login', 'post', { mobile, code })
}

// 获取个人信息
export const getUserInfo = () => request<UserInfo>('/patient/myUser')

// 病人信息
export const getPatientList = () => request<PatientList>('/patient/mylist')

// 添加病人
export const addPatient = (patient: Patient) => request('patient/add', 'post', patient)

// 获取病人详情
export const getPatient = (id: string) => request<Patient>(`/patient/info/${id}`)

// 编辑病人详情
export const editPatient = (patient: Patient) => request('/patient/update', 'put', patient)

// 删除病人信息
export const deletePatient = (id: string) => request(`/patient/del/${id}`, 'delete')
